//
//  XYTOrderListView.m
//  XYTPayOrderSystem
//
//  Created by wupeng on 2017/8/24.
//  Copyright © 2017年 wupeng. All rights reserved.
//

#import "XYTOrderListView.h"

@interface XYTOrderListView ()

@property (nonatomic, strong) UIView *sepLine1;
@property (nonatomic, strong) UIView *sepLine2;
@property (nonatomic, strong) UIView *sepLine3;
@property (nonatomic, strong) UIView *sepLine4;

@end

@implementation XYTOrderListView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
//        [self.layer setBorderWidth:1.0];
//        [self.layer setBorderColor:[UIColor lightGrayColor].CGColor];
        [self setupUI];
    }
    return self;
}

-(void)setupUI{
    self.backgroundColor = [UIColor clearColor];
    
    UILabel *telNumLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, boundsHeight)];
    telNumLab.font = [UIFont systemFontOfSize:12];
    telNumLab.textAlignment = NSTextAlignmentCenter;
    self.telNumLab = telNumLab;
    [self addSubview:telNumLab];
    
    UIView *sepLine1 = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(telNumLab.frame), 0, 1, boundsHeight)];
    sepLine1.backgroundColor = [UIColor lightGrayColor];
    self.sepLine1 = sepLine1;
    [self addSubview:sepLine1];
    
    UILabel *orderSumLab = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(sepLine1.frame), 0, boundsWidth - 80-50-120-25-1*4, boundsHeight)];
    orderSumLab.font = [UIFont systemFontOfSize:12];
    orderSumLab.textAlignment = NSTextAlignmentCenter;
    self.orderSumLab = orderSumLab;
    [self addSubview:orderSumLab];
    
    UIView *sepLine2 = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(orderSumLab.frame), 0, 1, boundsHeight)];
    sepLine1.backgroundColor = [UIColor lightGrayColor];
    self.sepLine2 = sepLine2;
    [self addSubview:sepLine2];
    
    UILabel *statusLab = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(sepLine2.frame), 0, 50, boundsHeight)];
    statusLab.font = [UIFont systemFontOfSize:12];
    statusLab.textAlignment = NSTextAlignmentCenter;
    self.statusLab = statusLab;
    [self addSubview:statusLab];
    
    UIView *sepLine3 = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(statusLab.frame), 0, 1, boundsHeight)];
    sepLine1.backgroundColor = [UIColor lightGrayColor];
    self.sepLine3 = sepLine3;
    [self addSubview:sepLine3];
    
    UILabel *timeLab = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(sepLine3.frame), 0, 120, boundsHeight)];
    timeLab.font = [UIFont systemFontOfSize:12];
    timeLab.textAlignment = NSTextAlignmentCenter;
    self.timeLab = timeLab;
    [self addSubview:timeLab];
    
    UIView *sepLine4 = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(timeLab.frame), 0, 1, boundsHeight)];
    sepLine1.backgroundColor = [UIColor lightGrayColor];
    self.sepLine4 = sepLine4;
    [self addSubview:sepLine4];
    
    UIButton *detailBtn = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(sepLine4.frame), 0, 25, boundsHeight)];
    detailBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    detailBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
    [detailBtn addTarget:self action:@selector(onClickDetail) forControlEvents:UIControlEventTouchUpInside];
    self.detailBtn = detailBtn;
    [self addSubview:detailBtn];
}

-(void)setSeparateColor:(UIColor *)separateColor{
    self.sepLine1.backgroundColor = separateColor;
    self.sepLine2.backgroundColor = separateColor;
    self.sepLine3.backgroundColor = separateColor;
    self.sepLine4.backgroundColor = separateColor;
}

- (void)onClickDetail{
    if (self.delegate && [self.delegate respondsToSelector:@selector(onClickShowDetail)]) {
        [self.delegate onClickShowDetail];
    }
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
